<?php
/* @var $this RoleAclController */
/* @var $model RoleAcl */
/* @var $form CActiveForm */
?>

<div class="form">

    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'role-acl-form',
        'enableAjaxValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,
        ),
            ));
    ?>

        <?php echo $form->errorSummary($model); ?>

    <div class="row">
        <?php echo $form->labelEx($model, 'rid'); ?>
<?php echo $form->dropDownList($model, 'rid', array('' => '') + CHtml::listData(Role::model()->findAll(), 'id', 'role_name')); ?>
<?php echo $form->error($model, 'rid'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'controller'); ?>
<?php echo $form->dropDownList($model, 'controller', array('' => '') + CHtml::listData(RoleSource::model()->findAll('pid=0'), 'source_value', 'source_name'), array('onchange' => 'getAction(this)')); ?>
<?php echo $form->error($model, 'controller'); ?>
        <script>
            function getAction(obj){
                $.post("<?php echo $this->createUrl('admin'); ?>", {ajax:"getSource", ps:$(obj).val()}, function(data){
                    $("#RoleAcl_action option").remove();
                    $("#RoleAcl_action").append("<option></option><option value='*'>所有操作</option>");
                    $.each(data, function(i, n){
                        $("#RoleAcl_action").append("<option value='" + n.value + "'>" + n.name + "</option>");
                    });
                }, "json");
            }
        </script>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'action'); ?>
<?php echo $form->dropDownList($model, 'action', array('' => '', '*' => '所有操作')); ?>
<?php echo $form->error($model, 'action'); ?>
    </div>

    <div class="row">
        <?php echo $form->labelEx($model, 'access'); ?>
<?php echo $form->dropDownList($model, 'access', array($model::ACTION_ALLOW => '允许', $model::ACTION_DENY => '禁用')); ?>
<?php echo $form->error($model, 'access'); ?>
    </div>

    <div class="row buttons">
    <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->